package com.cloud.code.牛客网;

/**
 * HJ75 公共子串计算
 * <p>
 * 这个题不能用双循环，会超时
 * <p>
 * afewfwafe
 * few
 */
public class Test17 {

    public static void main(String[] args) {
        String str1 = "afewfewfe";
        String str2 = "few";
        LCS(str1, str2);

    }

    public static String LCS(String str1, String str2) {


        int start = 0;
        int end = 1;
        String res = "";
        
        while (end <= str1.length()){
            String substring = str1.substring(start, end);
            if(str2.contains(substring)){
                res = substring;
            }else {
                start++;
            }
            end ++;

        }

        return res;

    }
}
